﻿@{
    Layout = "_Layout.cshtml";
    IQueryable<Post> posts = ViewBag.Posts;
    var topPost = Service.PostManager.Select(p => p.IsTop).OrderBy(p => p.PubDate).Take(2);
    
}
<div class="content-wrap">
    <div class="content">
        @if (topPost.Any())
        { 
            <div class="sticky">
                <h2 class="title">置顶推荐</h2>
                <ul>
                    @foreach (var item in topPost)
                    {
                        <li class="item">
                            <a href="@Url.Post(item.Slug)">
                                <img src="@item.Image(ThemeUrl + "img/thumbnail.png")" alt="@item.Title" />
                                <h3>@item.Title</h3>
                                <p class="muted">@item.Note(100)</p>
                            </a>
                        </li>
                    }
                </ul>
            </div>
        }
        <h2 class="title">最新发布</h2>
        @*<div class="banner banner-sticky">
            <div style="text-align: left; padding: 10px 20px; margin-bottom: -6px;">
                <!--广告位-->
            </div>
        </div>*@
        @foreach (var item in posts)
        {
            <article class="excerpt">
                <div class="focus">
                    <a href="@item.Link" class="thumbnail">
                        <img src="@item.Image(ThemeUrl + "img/thumbnail.png")" alt="@item.Title" />
                    </a>
                </div>
                <header>
                    @item.Categorys.ToHtml(Url, "<a href=\"{0}\" target=\"_blank\" class=\"label label-important\">{1}<i class=\"label-arrow\"></i></a>", TermType.PostCategory, string.Empty)
                    <h2><a href="@item.Link" title="@item.Title">@item.Title</a></h2>
                </header>
                <p>
                    <span class="muted"><i class="icon-user icon12"></i><a href="@Url.Author(item.Author.Login)">@item.Author.NickName</a></span>
                    <span class="muted"><i class="icon-time icon12"></i>@item.PubDate.ToString("MM-dd")</span>
                    <span class="muted"><i class="icon-eye-open icon12"></i>@item.ViewCount 浏览</span>
                    <span class="muted"><i class="icon-comment icon12"></i><a href="@item.Link#comments">@item.CommentCount 评论</a></span>
                </p>
                <p class="note">@item.Note(180)</p>
            </article>
        }
        <div class="pagination">@RenderPager((int)ViewBag.TotalCount, (int)ViewBag.CurrentPage)</div>
    </div>
</div>
@Include("_SideBar")
@section JsSetting{
    <script>
        window._wedn = {
            name: '斯通麦博',
            url: 'http://www.wedn.net',
            rss: 'http://www.wedn.net',
            maillist: 'off',
            maillistCode: '',
            commenton: 0,
            roll: [0]
        };
        //var ul = document.getElementById('menu_nav');
        //var lis = ul.getElementsByTagName('li');
        //for (var i = 0; i < lis.length; i++) {
        //    var alink = lis[i].getElementsByTagName('a')[0];
        //    if (alink.href === window.location.href) {
        //        lis[i].className = lis[i].className + ' current-' + lis[i].className;
        //        break;
        //    }
        //}
    </script>
}